# a CMake that works with pylon cam and OpenCV project
# created 05/11/14
# author: Shawn Le

cmake_minimum_required(VERSION 2.8)
project( vid_cam_calib ) 

set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}     "C:/Program Files/Basler/pylon 3.2"  # Laptop
												"D:/Program Files/Basler/pylon 4"
												"D:/Documents and Settings/SonLe/My Documents/SOFTs/OpenCV-2.4.2/opencv/build/"
												"D:/TEMP DRIVE/Softs/Mechatronics/OpenCV-2.4.2/OpenCV-2.4.2/opencv/build"
)												

#set(OpenCV_DIR "D:/opencv/build")   # desktop
set(OpenCV_DIR  #"D:/opencv/build"
                #"D:/Documents and Settings/SonLe/My Documents/SOFTs/OpenCV-2.4.2/opencv/build/"
                "D:/TEMP DRIVE/Softs/Mechatronics/OpenCV-2.4.2/OpenCV-2.4.2/opencv/build"  # laptop
)  

# find_package calls CMake module, if I don't use find_package, I can use target_link_libraries & link_directories combination instead
find_package( OpenCV REQUIRED core highgui imgproc objdetect calib3d features2d ml flann nonfree video contrib gpu legacy photo ts stitching) # 
find_package( Pylon) 

# check finding
IF (OpenCV_FOUND)
message("OpenCV is found\n")
ELSE (OpenCV_FOUND)
message("OpenCV is NOT found\n")
ENDIF (OpenCV_FOUND)


include_directories(${OpenCV_INCLUDE_DIRS} ${PYLON_INCLUDE_DIRS})
link_directories(${OpenCV_LIB_DIR} ${PYLON_LIBRARIES})

# NO  NEED  AFTER CALLING find_package, it depends on specific library's CMake module
#link_directories(   ${OpenCV_LIB_DIR} 
#								${PYLON_LIBRARIES}
#								"D:/Program Files/Basler/pylon 4/pylonc/lib/Win32"
#								"D:/Program Files/Basler/pylon 4/genicam/library/cpp/lib/win32_i86"
#)


message("OpenCV_LIB_DIR = ${OpenCV_LIB_DIR}")
message("OpenCV_INCLUDE_DIRS = ${OpenCV_INCLUDE_DIRS}")
message("OpenCV_DIR = ${OpenCV_DIR}")
message("OpenCV_LIBS = ${OpenCV_LIBS}")
#message("PYLON_LIBRARIES = ${PYLON_LIBRARIES}")

add_executable( vid_cam_calib main.cpp PylonGrabber.cpp)


# here only put the library names without path, coz' path is given in link_directories
target_link_libraries( vid_cam_calib ${OpenCV_LIBS} ${PYLON_LIBRARIES})
